﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HRMSys.Model;
using System.Data;

namespace HRMSys.DAL
{
    public class PositionDAL
    {
        /// <summary>
        /// 获得全部岗位
        /// </summary>
        /// <returns></returns>
        public Position[] GetAll()
        {
            string sql = "select * from T_Position";
            DataTable table = SqlHelper.ExecuteDataTable(sql);
            int dataCount = table.Rows.Count;
            Position[] positions = new Position[dataCount];
            for (int i = 0; i < dataCount; i++)
            {
                DataRow row = table.Rows[i];
                Position position = ToPosition(row);
                positions[i] = position;
            }
            return positions;
        }

        private Position ToPosition(DataRow row)
        {
            Position position = new Position();
            position.Id = (Guid)row["Id"];
            position.Name = (string)row["Name"];
            return position;
        }
    }
}
